const jwt2 = require('hapi-auth-jwt2');

exports.plugin = {
  name: 'authJwtPlugin',
  register: async (server) => {
    await server.register(jwt2);
    // 设置认证
    server.auth.strategy('jwt', 'jwt', {
      key: 'curd',
      validate() {
        return {
          isValid: true,
        };
      },
      verifyOptions: {
        algorithms: ['HS256'],
      },
      cookieKey: 'token',
    });
    server.auth.default('jwt');
  },
};
